﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using MyDMS.DAL;

public partial class UserRoles : PageBaseClass
{
    MyDMSEntity myDmsEntity=new MyDMSEntity();
    protected void Page_Load(object sender, EventArgs e)
    {
        List<UserRole> userRoles = myDmsEntity.UserRole.ToList();
        this.gvUserRoles.DataSource = userRoles;
        this.gvUserRoles.DataBind();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        UserRole uRole = new UserRole();
        uRole.Role_Name = txtRoleName.Text;
        uRole.Role_Description = txtDescription.Text;
        uRole.Office_Code = Author.office_Code;
        uRole.Creation_Date = DateTime.Now;
        uRole.Updation_Date = DateTime.Now;

        myDmsEntity.UserRole.AddObject(uRole);

        if (myDmsEntity.SaveChanges()>0)
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
